import axios from 'axios';

import { server_base_url } from '../config';
import { info } from './common';

export const market = {
    /**
     * 获取市场状态接口
     */
    async getMarketStatus() {
        try {
            const response = await axios.post(`${ server_base_url }/market/time`, {}, {
                headers: { 'Content-Type': 'application/json' }
            });
            const data = response.data;
            info('[ resposeData ] getMarketStatus', data);
            return { success: true, data };
        } catch (err) {
            info('[ err ] getMarketStatus', err);
            return { success: false, err };
        }
    },
    /**
     * 获取市场列表接口
     */
    async getMarketList() {
        try {
            const response = await axios.post(`${ server_base_url }/market/list`, {}, {
                headers: { 'Content-Type': 'application/json' }
            });
            const data = response.data;
            info('[ resposeData ] getMarketList', data);
            return { success: true, data };
        } catch (err) {
            info('[ err ] getMarketList', err);
            return { success: false, err };
        }
    },
};
